import { Provide, Inject } from '@midwayjs/core';
import { BaseService } from '@cool-midway/core';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { Repository } from 'typeorm';
import { OrderMerchantEntity } from '../entity/merchant';
import { OrderZhongtianService } from './zhongtian';

/**
 * 订单模块-店铺信息Service
 */
@Provide()
export class OrderMerchantService extends BaseService {
    @InjectEntityModel(OrderMerchantEntity)
    orderMerchantEntity: Repository<OrderMerchantEntity>;

    @Inject()
    orderZhongtianService: OrderZhongtianService;

    // 重写add方法  
    async add(param) {
        // 添加时顺便注册为一个新的顾客
        // const customer = await this.orderZhongtianService.createCustomer({
        //     c_clientname: param.merchantName,
        //     c_sex: 'M',
        //     c_mt: param.merchantPhone,
        // });
        // param.merchantId = customer;
        const result = await super.add(param);
        return result;
    }
}
